package Work4;

import java.util.Arrays;
import java.util.Scanner;

public class Pro5 {

	public static void main(String[] args) {
		int flag = 0;
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		PersonOverride[] person1 = new PersonOverride[n];
		PersonOverride[] person2 = new PersonOverride[m];
		for (int i = 0; i < n; i++) {
			person1[i] = new PersonOverride();
		}
		
		for (int i = 0; i < person2.length; i++) {
			PersonOverride tempperson = new PersonOverride(in.next(), in.nextInt(),
					in.nextBoolean());
			if( i == 0 )
				{
				person2[i] = tempperson;
				continue;
				}
			for (int j = 0; j < i; j++) {
				if(person2[j] != null)
				if(tempperson.equals(person2[j]))
					flag = 1;
			}
			if (flag == 0)
				{
				person2[i] = tempperson;
				}
			flag = 0;

		}
		for (int i = 0; i < person1.length; i++) {
			System.out.println(person1[i]);
		}
		int count = 0;
		for (int i = 0; i < person2.length; i++) {
			if(person2[i] != null){
			System.out.println(person2[i]);
			count++;}
		}
		System.out.println(count);
		System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
	}
}

class PersonOverride {
	private String name;
	private boolean gender = false;
	private int age = 0;

	
	public PersonOverride() {
		this("default", 1, true);
	}
	public PersonOverride(String name, int age, boolean gender) {
		this.name = name;
		this.gender = gender;
		this.age = age;
	}



	@Override
	public String toString() {
		return name + "-" + age + "-" + gender;
	}

	public boolean equals(PersonOverride person) {
		if (this.name.equals(person.name) && this.age == person.age && this.gender == person.gender)
			return true;

		return false;	
	}

}
